<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
          + request.getServerName() + ":" + request.getServerPort()
          + path;
  request.setAttribute("basePath", basePath);
%>


<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>用户列表</title>
  <base href="${basePath}/static/admin/">
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="后台模板,后台管理系统,HTML模板">
<meta name="description" content="基于Bootstrap的后台管理系统模板">
<meta name="author" content="www.bootstrapmb.com">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/fonts.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
  
<body>
    <!--页面主要内容-->
    <main class="ftdms-layout-content">
      
      <div class="container-fluid" style="margin-bottom:90px;">
        
        <div class="row" style="margin-top:15px;">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form class="pull-right search-bar" method="get" action="#!" role="form">
                  <div class="input-group">
                    <div class="input-group-btn">
                      <input type="hidden" name="search_field" id="search-field" value="title">
                      <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                      标题 <span class="caret"></span>
                      </button>
                      <ul class="dropdown-menu">
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="title">标题</a> </li>
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="cat_name">栏目</a> </li>
                      </ul>
                    </div>
                    <input type="text" class="form-control" value="" name="keyword" placeholder="请输入名称">
                  </div>
                </form>
                <%--<div class="toolbar-btn-action">
				  <a class="btn btn-primary m-r-5 submenuitem" href="../../admin/touserupdate.action" data-id="link552" data-index="552"> 新增</a>
                  <a class="btn btn-success m-r-5 submenuitem" href="pages_data.html" data-id="link553" data-index="553"> 启用</a>
                  <a class="btn btn-warning m-r-5 submenuitem" href="pages_data.html" data-id="link554" data-index="554"> 禁用</a>
                  <a class="btn btn-danger submenuitem" onclick="deletefun()" data-id="link555" data-index="555"> 删除</a>
                </div>--%>
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th width="5">
                          <label class="ftdms-checkbox checkbox-primary">
                            <input type="checkbox" id="check-all"><span></span>
                          </label>
                        </th>
                        <th>用户编号</th>
                        <th>用户密码</th>
                        <th>用户性别</th>
                        <th>用户年龄</th>
                        <th>用户电话</th>
                        <th>用户地址</th>
                        <th>用户名称</th>
                        <th>更改角色</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      <c:forEach var="user" items="${page.pageInfo.list}">
                        <tr>
                          <td>
                            <label class="ftdms-checkbox checkbox-primary">
                              <input type="checkbox" name="arrays" value="${user.uId}"><span></span>
                            </label>
                          </td>
                          <td>${user.uId}</td>
                          <td>${user.uPass}</td>
                          <td>${user.uSex}</td>
                          <td>${user.uAge}</td>
                          <td>${user.uTel}</td>
                          <td>${user.uAdress}</td>
                          <td>${user.uName}</td>
                          <td>${user.rName}</td>
                          <td>
                            <div class="btn-group">
                              <a class="btn btn-xs btn-default submenuitem" href="../../admin/touserupdate.action?uId=${user.uId}" target= "_self" title="编辑" data-toggle="tooltip"><i class="ftsucai-edit-2"></i></a>
                              <a class="btn btn-xs btn-default submenuitem" onclick="deleteone(${user.uId})" target= "_self" title="删除" data-toggle="tooltip"><i class="ftsucai-del-2"></i></a>
                            </div>
                          </td>
                        </tr>
                      </c:forEach>

                    </tbody>
                  </table>
                </div>
                <ul class="pagination">
                  <li><a href="${pageContext.request.contextPath}${page.servletUrl}">首页</a></li>
                  <li><a href="${pageContext.request.contextPath}${page.servletUrl}?pageNum=${page.pageInfo.pageNum-1}">上一页</a></li>
                  <c:forEach begin="${page.pageInfo.navigateFirstPage}" end="${page.pageInfo.navigateLastPage}" var="a">
                    <li><a href="${pageContext.request.contextPath}${page.servletUrl}?pageNum=${a}">${a}</a></li>
                  </c:forEach>
                  <li><a href="${pageContext.request.contextPath}${page.servletUrl}?pageNum=${page.pageInfo.pageNum==page.pageInfo.pages?page.pageInfo.pageNum:page.pageInfo.pageNum+1}">下一页</a></li>
                  <li><a href="${pageContext.request.contextPath}${page.servletUrl}?pageNum=${page.pageInfo.pages}">尾页</a></li>
                </ul>
       
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });
});

function deleteone(userId){
  if(confirm("确定要删除吗")){
    window.location.href = "../../admin/userdelete.action?uId="+userId;
  }
}

function deletefun(){
  var checks = $('input[type="checkbox"]:checked');
  console.log(checks);
  console.log(checks.length);
  var checkall = $("#check-all");
  var flag = checkall.is(":checked");
  if(checks.length>1||checks.length==1&&flag==false){
    var flag = confirm("确定要删除选中的用户吗");
    if(flag){
      $("#form1").submit();
    }
  }else {
    alert("至少选中一个用户")
  }
}
</script>
</body>
</html>